home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / amiga / plotting / gnuplot3.lzh / gnuplot / docs / doc2hlp.c < prev    next >
C/C++ Source or Header  |  1991-07-11  |  1KB  |  75 lines

  1. /*
  2.  * doc2hlp.c  -- program to convert Gnuplot .DOC format to 
  3.  * VMS help (.HLP) format.
  4.  *
  5.  * This involves stripping all lines with a leading ?,
  6.  * @, #, or %.
  7.  * Modified by Russell Lang from hlp2ms.c by Thomas Williams 
  8.  *
  9.  * usage:  doc2hlp < file.doc > file.hlp
  10.  *
  11.  * Original version by David Kotz used the following one line script!
  12.  * sed '/^[?@#%]/d' file.doc > file.hlp
  13.  */
  14.  
  15. #include <stdio.h>
  16. #include <ctype.h>
  17.  
  18. #define MAX_LINE_LEN    256
  19. #define TRUE 1
  20. #define FALSE 0
  21.  
  22. main()
  23. {
  24.     convert(stdin,stdout);
  25.     exit(0);
  26. }
  27.  
  28.  
  29. convert(a,b)
  30.     FILE *a,*b;
  31. {
  32.     static char line[MAX_LINE_LEN];
  33.  
  34.     while (fgets(line,MAX_LINE_LEN,a)) {
  35.        process_line(line, b);
  36.     }
  37. }
  38.  
  39. process_line(line, b)
  40.     char *line;
  41.     FILE *b;
  42. {
  43.     static int line_count = 0;
  44.  
  45.     line_count++;
  46.  
  47.     switch(line[0]) {        /* control character */
  48.        case '?': {            /* interactive help entry */
  49.           break;            /* ignore */
  50.        }
  51.        case '@': {            /* start/end table */
  52.           break;            /* ignore */
  53.        }
  54.        case '#': {            /* latex table entry */
  55.           break;            /* ignore */
  56.        }
  57.        case '%': {            /* troff table entry */
  58.           break;            /* ignore */
  59.        }
  60.        case '\n':            /* empty text line */
  61.        case ' ': {            /* normal text line */
  62.           (void) fputs(line,b); 
  63.           break;
  64.        }
  65.        default: {
  66.           if (isdigit(line[0])) { /* start of section */
  67.             (void) fputs(line,b); 
  68.           } else
  69.             fprintf(stderr, "unknown control code '%c' in column 1, line %d\n", 
  70.                   line[0], line_count);
  71.           break;
  72.        }
  73.     }
  74. }
  75.